/**
 * Created by zhang on 2017/6/6.
 */
angular.module('app', ['ui.tabs']).controller('tabCtrl',function () {

})
    .controller('MyController', function ($rootScope,$scope, uiTabs) {

        $rootScope.uiTabs=uiTabs;

        var index = 0;

        $scope.$on('tabChangeStart', function (e, tab) {
        });

        $scope.$on('tabChangeSuccess', function (e, tab) {
             console.log(tab);
            $scope.currentTab = uiTabs.current;
        });

        $scope.$on('manualRefresh', function (e, tab) {
            console.log("manualRefresh",tab);

        });

        $scope.tabs = uiTabs.tabs;

        $scope.addTab = function () {
            uiTabs.open({
                name: 'index' + (++index),
                templateUrl: index+'.html'
            });
        };

        $scope.closeTab = function (tab) {
            console.log("uiTabs.close(tab);");
            uiTabs.close(tab);
        };

        $scope.active = function (tab) {
            uiTabs.active(tab);
        };

        $scope.closeAll = function () {
            uiTabs.closeAll();
        }

        $scope.replaceTab=function(tab,newTab) {

            // body...
            console.log("replaceTab。。。。。。。。。");

            uiTabs.replace( $scope.currentTab,{'templateUrl':'2.html'});

        }


    })
    